<!-- <template>
    <Center>
        <h1>正在登录中......</h1>
    </Center>
</template>

<script>
import {mapState} from 'vuex';
import Center from '@/components/Center.vue'

export default {
  components: { Center },
  computed: {...mapState("userStore",["user"])},
  methods: {
    handleLogin(){
        this.$router.push({name:"Login"})
    }
  },
  watch: {
    user:{
      immediate:true,
      handler(){
        this.handleLogin();
      }
    },
    isLoading:{
      immediate:true,
      handler(){
        this.handleLogin();
      }
    },
  },
}
</script>
<style></style> -->
<template>
    <Center>
        <h1>正在登录中......</h1>
    </Center>
</template>
<script>
import {mapState} from 'vuex';
import Center from '@/components/Center.vue'
export default {
  components: { Center },
  computed: {...mapState("userStore",["user","isLoading"])},
  methods: {
    handleLogin(){
      if(this.isLoading){
        return;
      }
      if(this.user){
        this.$router.push({name:"Menu"})
      }else{
        this.$router.push({name:"Login"})
      }
    }
  },
  watch: {
    user:{
      immediate:true,
      handler(){
        this.handleLogin();
      }
    },
    isLoading:{
      immediate:true,
      handler(){
        this.handleLogin();
      }
    },
  },
}
</script>
<style></style>